package com.qian.ddj.web.controller;

import com.qian.api.ddj.model.MoneyMap;
import com.qian.api.ddj.service.IMoneyMapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ddj/moneyMap")
@Api(tags = "金额转换管理")
public class MoneyMapController {

    @Autowired
    private IMoneyMapService moneyMapService;

    @GetMapping("/list/{id}")
    @ApiOperation("转换列表")
    public List<MoneyMap> list(@PathVariable Integer id) {
        MoneyMap moneyMap = new MoneyMap();
        moneyMap.setGroupId(id);
        List<MoneyMap> moneyMaps = moneyMapService.findAll(moneyMap);
        return moneyMaps;
    }

    @PostMapping
    @ApiOperation("保存")
    public MoneyMap save(MoneyMap moneyMap) {
        moneyMap = moneyMapService.save(moneyMap);
        return moneyMap;
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public void delete(@PathVariable Integer id) {
        moneyMapService.deleteById(id);
    }
}
